class Solution {
public:
    bool isAnagram(string s, string t) {
        int mp[26] = {0};
        for (int i = 0; i < s.size(); i++) {
            mp[s[i] - 'a'] += 1;
        }
        bool flag = true;
        for (int i = 0; flag && i < t.size(); i++) {
            if (mp[t[i] - 'a'] == 0) flag = false;
            else mp[t[i] - 'a']--;
        }
        return flag && s.size() == t.size();
    }
};
